#pragma once

// simulate login service

enum class DataType
{
	LOG_IN, LOGIN_OK, LOGIN_FAILED, LOG_OUT,
	PERSON_INFO,
	REQUEST_ERROR
};

// 1 fisrt get response type, then get request data
struct DataTypePackage {
	DataType data_type;
	unsigned int data_length;
};
// login data
struct Login : public DataTypePackage {

	Login() {
		data_type = DataType::LOG_IN;
		data_length = sizeof(Login);

		// may cause local variable mem be clear!!!
		// memset(name, 0, strlen(name));
		// memset(passwd, 0, strlen(passwd));
	}

	char name[128];
	char passwd[128];

};

struct LoginOk : public DataTypePackage {

	LoginOk() {
		data_type = DataType::LOGIN_OK;
		data_length = sizeof(LoginOk);
	}

	char name[128];

};

struct LoginFailed : public DataTypePackage {

	LoginFailed() {
		data_type = DataType::LOGIN_FAILED;
		data_length = sizeof(LoginFailed);
	}

	char msg[128];

};

struct LogOut : public DataTypePackage {

	LogOut() {
		data_type = DataType::LOG_OUT;
		data_length = sizeof(LogOut);
	}

	char name[128];

};

// use struct
struct PersonInfo : public DataTypePackage {

	PersonInfo() {
		data_type = DataType::PERSON_INFO;
		data_length = sizeof(PersonInfo);
		age = 0;
	}

	char name[128];
	unsigned int age;

};

struct RequestError : public DataTypePackage {

	RequestError() {
		data_type = DataType::REQUEST_ERROR;
		data_length = sizeof(RequestError);
	}

	char msg[128];

};

